home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 August / CICA - The Ultimate Collection of Shareware for Windows (Disc 2) (August 1995).iso / disc2 / demo / pwrtcp11.exe / TCPEX.FRM < prev    next >
Text File  |  1995-02-16  |  12KB  |  369 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "TCP Example"
  4.    ClientHeight    =   5820
  5.    ClientLeft      =   1272
  6.    ClientTop       =   1596
  7.    ClientWidth     =   7368
  8.    Height          =   6192
  9.    Icon            =   TCPEX.FRX:0000
  10.    Left            =   1224
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5820
  13.    ScaleWidth      =   7368
  14.    Top             =   1272
  15.    Width           =   7464
  16.    Begin CommandButton cmdExit 
  17.       Caption         =   "E&xit"
  18.       Height          =   375
  19.       Left            =   120
  20.       TabIndex        =   14
  21.       Top             =   120
  22.       Width           =   1215
  23.    End
  24.    Begin Frame Frame3 
  25.       Caption         =   "Connected &From"
  26.       Height          =   3855
  27.       Left            =   3720
  28.       TabIndex        =   13
  29.       Top             =   1800
  30.       Width           =   3495
  31.       Begin PowerTCP_TCP tcpConnectFrom 
  32.          Flags           =   0
  33.          Left            =   720
  34.          LocalDotAddr    =   ""
  35.          OemLicense      =   ""
  36.          RemoteHost      =   ""
  37.          RemotePort      =   7
  38.          Top             =   360
  39.       End
  40.       Begin CommandButton cmdConnectFromSend 
  41.          Caption         =   "Se&nd"
  42.          Enabled         =   0   'False
  43.          Height          =   375
  44.          Left            =   2160
  45.          TabIndex        =   20
  46.          Top             =   720
  47.          Width           =   1215
  48.       End
  49.       Begin TextBox txtConnectFromSend 
  50.          Height          =   375
  51.          Left            =   120
  52.          TabIndex        =   19
  53.          Top             =   720
  54.          Width           =   1935
  55.       End
  56.       Begin CommandButton cmdConnectFromClose 
  57.          Caption         =   "Clo&se"
  58.          Enabled         =   0   'False
  59.          Height          =   375
  60.          Left            =   2160
  61.          TabIndex        =   16
  62.          Top             =   240
  63.          Width           =   1215
  64.       End
  65.       Begin TextBox txtConnectFrom 
  66.          FontBold        =   0   'False
  67.          FontItalic      =   0   'False
  68.          FontName        =   "Fixedsys"
  69.          FontSize        =   10.8
  70.          FontStrikethru  =   0   'False
  71.          FontUnderline   =   0   'False
  72.          Height          =   2535
  73.          Left            =   120
  74.          MultiLine       =   -1  'True
  75.          ScrollBars      =   2  'Vertical
  76.          TabIndex        =   15
  77.          Top             =   1200
  78.          Width           =   3255
  79.       End
  80.    End
  81.    Begin Frame Frame2 
  82.       Caption         =   "&Listen"
  83.       Height          =   1455
  84.       Left            =   3720
  85.       TabIndex        =   0
  86.       Top             =   120
  87.       Width           =   3495
  88.       Begin PowerTCP_TCP tcpListen 
  89.          Flags           =   0
  90.          Left            =   540
  91.          LocalDotAddr    =   ""
  92.          OemLicense      =   ""
  93.          RemoteHost      =   ""
  94.          RemotePort      =   7
  95.          Top             =   960
  96.       End
  97.       Begin CommandButton cmdStop 
  98.          Caption         =   "&Stop"
  99.          Enabled         =   0   'False
  100.          Height          =   375
  101.          Left            =   2040
  102.          TabIndex        =   4
  103.          Top             =   840
  104.          Width           =   1215
  105.       End
  106.       Begin TextBox txtListenPort 
  107.          Height          =   375
  108.          Left            =   600
  109.          TabIndex        =   2
  110.          Text            =   "23"
  111.          Top             =   360
  112.          Width           =   1215
  113.       End
  114.       Begin CommandButton cmdListen 
  115.          Caption         =   "&Listen"
  116.          Height          =   375
  117.          Left            =   2040
  118.          TabIndex        =   3
  119.          Top             =   360
  120.          Width           =   1215
  121.       End
  122.       Begin Label Label3 
  123.          Caption         =   "&Port:"
  124.          Height          =   375
  125.          Left            =   120
  126.          TabIndex        =   1
  127.          Top             =   360
  128.          Width           =   1215
  129.       End
  130.    End
  131.    Begin Frame Frame1 
  132.       Caption         =   "Connect &To"
  133.       Height          =   4935
  134.       Left            =   120
  135.       TabIndex        =   5
  136.       Top             =   720
  137.       Width           =   3495
  138.       Begin PowerTCP_TCP tcpConnectTo 
  139.          Flags           =   0
  140.          Left            =   180
  141.          LocalDotAddr    =   ""
  142.          OemLicense      =   ""
  143.          RemoteHost      =   ""
  144.          RemotePort      =   7
  145.          Top             =   1200
  146.       End
  147.       Begin CommandButton cmdConnectToSend 
  148.          Caption         =   "&Send"
  149.          Enabled         =   0   'False
  150.          Height          =   375
  151.          Left            =   2160
  152.          TabIndex        =   18
  153.          Top             =   1800
  154.          Width           =   1215
  155.       End
  156.       Begin TextBox txtConnectToSend 
  157.          Height          =   375
  158.          Left            =   120
  159.          TabIndex        =   17
  160.          Top             =   1800
  161.          Width           =   1935
  162.       End
  163.       Begin CommandButton cmdConnectToClose 
  164.          Caption         =   "C&lose"
  165.          Enabled         =   0   'False
  166.          Height          =   375
  167.          Left            =   2160
  168.          TabIndex        =   11
  169.          Top             =   1200
  170.          Width           =   1215
  171.       End
  172.       Begin TextBox txtConnectToPort 
  173.          Height          =   375
  174.          Left            =   2040
  175.          TabIndex        =   9
  176.          Text            =   "23"
  177.          Top             =   600
  178.          Width           =   1335
  179.       End
  180.       Begin TextBox txtConnectToAddress 
  181.          Height          =   375
  182.          Left            =   120
  183.          TabIndex        =   7
  184.          Text            =   "x.x.x.x"
  185.          Top             =   600
  186.          Width           =   1335
  187.       End
  188.       Begin CommandButton cmdConnect 
  189.          Caption         =   "&Connect"
  190.          Height          =   375
  191.          Left            =   720
  192.          TabIndex        =   10
  193.          Top             =   1200
  194.          Width           =   1215
  195.       End
  196.       Begin TextBox txtConnectTo 
  197.          FontBold        =   0   'False
  198.          FontItalic      =   0   'False
  199.          FontName        =   "Fixedsys"
  200.          FontSize        =   10.8
  201.          FontStrikethru  =   0   'False
  202.          FontUnderline   =   0   'False
  203.          Height          =   2535
  204.          Left            =   120
  205.          MultiLine       =   -1  'True
  206.          ScrollBars      =   2  'Vertical
  207.          TabIndex        =   12
  208.          Top             =   2280
  209.          Width           =   3255
  210.       End
  211.       Begin Label Label2 
  212.          Caption         =   "&Port:"
  213.          Height          =   495
  214.          Left            =   2040
  215.          TabIndex        =   8
  216.          Top             =   360
  217.          Width           =   1215
  218.       End
  219.       Begin Label Label1 
  220.          Caption         =   "&Address:"
  221.          Height          =   495
  222.          Left            =   120
  223.          TabIndex        =   6
  224.          Top             =   360
  225.          Width           =   1215
  226.       End
  227.    End
  228. End
  229.  
  230. ' IMPORTANT: We MUST use the API MessageBox function
  231. ' instead of the VB MsgBox function. See the PowerTCP
  232. ' README for more information.
  233. Declare Function MessageBox Lib "User" (ByVal hWnd As Integer, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Integer) As Integer
  234.  
  235. Sub cmdConnect_Click ()
  236.     ' Set the properties of the remote computer
  237.     tcpConnectTo.RemoteHost = txtConnectToAddress.Text
  238.     tcpConnectTo.RemotePort = Val(txtConnectToPort.Text)
  239.  
  240.     ' Make the connection
  241.     tcpConnectTo.Action = CONNECT
  242. End Sub
  243.  
  244. Sub cmdConnectFromClose_Click ()
  245.     tcpConnectFrom.Action = CLOSECOMM
  246. End Sub
  247.  
  248. Sub cmdConnectFromSend_Click ()
  249.     tcpConnectFrom.Send = txtConnectFromSend.Text
  250. End Sub
  251.  
  252. Sub cmdConnectToClose_Click ()
  253.     tcpConnectTo.Action = CLOSECOMM
  254. End Sub
  255.  
  256. Sub cmdConnectToSend_Click ()
  257.     tcpConnectTo.Send = txtConnectToSend.Text
  258. End Sub
  259.  
  260. Sub cmdExit_Click ()
  261.     tcpConnectTo.Action = ABORTCOMM
  262.     tcpListen.Action = ABORTCOMM
  263.     tcpConnectFrom.Action = ABORTCOMM
  264.     End
  265. End Sub
  266.  
  267. Sub cmdListen_Click ()
  268.     ' Set the mode of tcpListen to Listen
  269.     tcpListen.LocalPort = Val(txtListenPort.Text)
  270.     tcpListen.Action = LISTEN
  271. End Sub
  272.  
  273. Sub cmdStop_Click ()
  274.     tcpListen.Action = CLOSECOMM
  275. End Sub
  276.  
  277. Sub Form_Unload (Cancel As Integer)
  278.     End
  279. End Sub
  280.  
  281. Sub tcpConnectFrom_Connect ()
  282.     cmdConnectFromClose.Enabled = True
  283.     cmdConnectFromSend.Enabled = True
  284. End Sub
  285.  
  286. Sub tcpConnectFrom_Exception (ErrorCode As Integer, ErrorDesc As String)
  287.     ' An unexpected error occurred--
  288.     ' notify the user and close the connection
  289.     suc% = MessageBox(Me.hWnd, ErrorDesc, App.Title, 0)
  290.     tcpConnectFrom.Action = CLOSECOMM
  291. End Sub
  292.  
  293. Sub tcpConnectFrom_Recv (RecvData As String)
  294.     If RecvData = "" Then
  295.         suc% = MessageBox(Me.hWnd, "The connection was closed.", App.Title, 0)
  296.         cmdConnectFromClose.Enabled = False
  297.         cmdConnectFromSend.Enabled = False
  298.     Else
  299.         txtConnectFrom.Text = txtConnectFrom.Text & Chr$(13) & Chr$(10) & Format$(tcpConnectFrom.RemoteHost) & ":" & Chr$(9) & RecvData
  300.     End If
  301. End Sub
  302.  
  303. Sub tcpConnectFrom_Send (SendInstance As Long)
  304.     ' Clear the text box to let the user know
  305.     ' the data was sent
  306.     txtConnectFrom.Text = txtConnectFrom.Text & Chr$(13) & Chr$(10) & "Me:" & Chr$(9) & txtConnectFromSend.Text
  307.     txtConnectFromSend.Text = ""
  308. End Sub
  309.  
  310. Sub tcpConnectTo_Connect ()
  311.     ' Make the Connect button disabled,
  312.     ' and the Close and Send buttons enabled.
  313.     cmdConnect.Enabled = False
  314.     cmdConnectToClose.Enabled = True
  315.     cmdConnectToSend.Enabled = True
  316. End Sub
  317.  
  318. Sub tcpConnectTo_Exception (ErrorCode As Integer, ErrorDesc As String)
  319.     ' An unexpected error occurred--
  320.     ' notify the user
  321.     suc% = MessageBox(Me.hWnd, ErrorDesc, App.Title, 0)
  322. End Sub
  323.  
  324. Sub tcpConnectTo_Recv (RecvData As String)
  325.     If RecvData = "" Then
  326.         ' The connection was closed
  327.         cmdConnect.Enabled = True
  328.         cmdConnectToClose.Enabled = False
  329.         cmdConnectToSend.Enabled = False
  330.         suc% = MessageBox(Me.hWnd, "The connection was closed.", App.Title, 0)
  331.     Else
  332.         txtConnectTo.Text = txtConnectTo.Text & Chr$(13) & Chr$(10) & Format$(tcpConnectTo.RemoteHost) & ":" & Chr$(9) & RecvData
  333.     End If
  334. End Sub
  335.  
  336. Sub tcpConnectTo_Send (SendInstance As Long)
  337.     ' Clear the text box to let the user know
  338.     ' the data was sent
  339.     txtConnectTo.Text = txtConnectTo.Text & Chr$(13) & Chr$(10) & "Me:" & Chr$(9) & txtConnectToSend.Text
  340.     txtConnectToSend.Text = ""
  341. End Sub
  342.  
  343. Sub tcpListen_Accept (NewSession As Long)
  344.     ' We must pass the connection on to tcpConnectFrom
  345.     If tcpConnectFrom.State = CLOSED Then tcpConnectFrom.Session = NewSession
  346. End Sub
  347.  
  348. Sub tcpListen_Exception (ErrorCode As Integer, ErrorDesc As String)
  349.     ' An unexpected error occurred--
  350.     ' notify the user and close the connection
  351.     suc% = MessageBox(Me.hWnd, ErrorDesc, App.Title, 0)
  352.     tcpListen.Action = CLOSECOMM
  353. End Sub
  354.  
  355. Sub tcpListen_Listen ()
  356.     ' Make the Listen button disabled,
  357.     ' and the Stop button enabled.
  358.     cmdListen.Enabled = False
  359.     cmdStop.Enabled = True
  360. End Sub
  361.  
  362. Sub tcpListen_Recv (RecvData As String)
  363.     ' The connection was closed
  364.     cmdStop.Enabled = False
  365.     cmdListen.Enabled = True
  366.     suc% = MessageBox(Me.hWnd, "Listening was stopped.", App.Title, 0)
  367. End Sub
  368.  
  369.